% Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite

{\ttfamily \raggedright {
\noindent
\mbox{}\textcolor{ForestGreen}{int}\ cap\textcolor{BrickRed}{[}MAXN\textcolor{BrickRed}{+}\textcolor{Purple}{1}\textcolor{BrickRed}{][}MAXN\textcolor{BrickRed}{+}\textcolor{Purple}{1}\textcolor{BrickRed}{],}\ flow\textcolor{BrickRed}{[}MAXN\textcolor{BrickRed}{+}\textcolor{Purple}{1}\textcolor{BrickRed}{][}MAXN\textcolor{BrickRed}{+}\textcolor{Purple}{1}\textcolor{BrickRed}{],}\ prev\textcolor{BrickRed}{[}MAXN\textcolor{BrickRed}{+}\textcolor{Purple}{1}\textcolor{BrickRed}{];} \\
\mbox{} \\
\mbox{}\textit{\textcolor{Brown}{/*}} \\
\mbox{}\textit{\textcolor{Brown}{\ \ cap[i][j]\ =\ Capacidad\ de\ la\ arista\ (i,\ j).}} \\
\mbox{}\textit{\textcolor{Brown}{\ \ flow[i][j]\ =\ Flujo\ actual\ de\ i\ a\ j.}} \\
\mbox{}\textit{\textcolor{Brown}{\ \ prev[i]\ =\ Predecesor\ del\ nodo\ i\ en\ un\ camino\ de\ aumentación.}} \\
\mbox{}\textit{\textcolor{Brown}{\ */}} \\
\mbox{} \\
\mbox{}\textcolor{ForestGreen}{int}\ \textbf{\textcolor{Black}{fordFulkerson}}\textcolor{BrickRed}{(}\textcolor{ForestGreen}{int}\ n\textcolor{BrickRed}{,}\ \textcolor{ForestGreen}{int}\ s\textcolor{BrickRed}{,}\ \textcolor{ForestGreen}{int}\ t\textcolor{BrickRed}{)}\textcolor{Red}{\{} \\
\mbox{}\ \ \textcolor{ForestGreen}{int}\ ans\ \textcolor{BrickRed}{=}\ \textcolor{Purple}{0}\textcolor{BrickRed}{;} \\
\mbox{}\ \ \textbf{\textcolor{Blue}{for}}\ \textcolor{BrickRed}{(}\textcolor{ForestGreen}{int}\ i\textcolor{BrickRed}{=}\textcolor{Purple}{0}\textcolor{BrickRed}{;}\ i\textcolor{BrickRed}{$<$}n\textcolor{BrickRed}{;}\ \textcolor{BrickRed}{++}i\textcolor{BrickRed}{)}\ \textbf{\textcolor{Black}{fill}}\textcolor{BrickRed}{(}flow\textcolor{BrickRed}{[}i\textcolor{BrickRed}{],}\ flow\textcolor{BrickRed}{[}i\textcolor{BrickRed}{]+}n\textcolor{BrickRed}{,}\ \textcolor{Purple}{0}\textcolor{BrickRed}{);} \\
\mbox{}\ \ \textbf{\textcolor{Blue}{while}}\ \textcolor{BrickRed}{(}\textbf{\textcolor{Blue}{true}}\textcolor{BrickRed}{)}\textcolor{Red}{\{} \\
\mbox{}\ \ \ \ \textbf{\textcolor{Black}{fill}}\textcolor{BrickRed}{(}prev\textcolor{BrickRed}{,}\ prev\textcolor{BrickRed}{+}n\textcolor{BrickRed}{,}\ \textcolor{BrickRed}{-}\textcolor{Purple}{1}\textcolor{BrickRed}{);} \\
\mbox{}\ \ \ \ queue\textcolor{BrickRed}{$<$}\textcolor{ForestGreen}{int}\textcolor{BrickRed}{$>$}\ q\textcolor{BrickRed}{;} \\
\mbox{}\ \ \ \ q\textcolor{BrickRed}{.}\textbf{\textcolor{Black}{push}}\textcolor{BrickRed}{(}s\textcolor{BrickRed}{);} \\
\mbox{}\ \ \ \ \textbf{\textcolor{Blue}{while}}\ \textcolor{BrickRed}{(}q\textcolor{BrickRed}{.}\textbf{\textcolor{Black}{size}}\textcolor{BrickRed}{()}\ \textcolor{BrickRed}{\&\&}\ prev\textcolor{BrickRed}{[}t\textcolor{BrickRed}{]}\ \textcolor{BrickRed}{==}\ \textcolor{BrickRed}{-}\textcolor{Purple}{1}\textcolor{BrickRed}{)}\textcolor{Red}{\{} \\
\mbox{}\ \ \ \ \ \ \textcolor{ForestGreen}{int}\ u\ \textcolor{BrickRed}{=}\ q\textcolor{BrickRed}{.}\textbf{\textcolor{Black}{front}}\textcolor{BrickRed}{();} \\
\mbox{}\ \ \ \ \ \ q\textcolor{BrickRed}{.}\textbf{\textcolor{Black}{pop}}\textcolor{BrickRed}{();} \\
\mbox{}\ \ \ \ \ \ \textbf{\textcolor{Blue}{for}}\ \textcolor{BrickRed}{(}\textcolor{ForestGreen}{int}\ v\ \textcolor{BrickRed}{=}\ \textcolor{Purple}{0}\textcolor{BrickRed}{;}\ v\textcolor{BrickRed}{$<$}n\textcolor{BrickRed}{;}\ \textcolor{BrickRed}{++}v\textcolor{BrickRed}{)} \\
\mbox{}\ \ \ \ \ \ \ \ \textbf{\textcolor{Blue}{if}}\ \textcolor{BrickRed}{(}\ v\ \textcolor{BrickRed}{!=}\ s\ \textcolor{BrickRed}{\&\&}\ prev\textcolor{BrickRed}{[}v\textcolor{BrickRed}{]}\ \textcolor{BrickRed}{==}\ \textcolor{BrickRed}{-}\textcolor{Purple}{1}\ \textcolor{BrickRed}{\&\&}\ cap\textcolor{BrickRed}{[}u\textcolor{BrickRed}{][}v\textcolor{BrickRed}{]}\ \textcolor{BrickRed}{$>$}\ flow\textcolor{BrickRed}{[}u\textcolor{BrickRed}{][}v\textcolor{BrickRed}{]}\ \textcolor{BrickRed}{)} \\
\mbox{}\ \ \ \ \ \ \ \ \ \ prev\textcolor{BrickRed}{[}v\textcolor{BrickRed}{]}\ \textcolor{BrickRed}{=}\ u\textcolor{BrickRed}{,}\ q\textcolor{BrickRed}{.}\textbf{\textcolor{Black}{push}}\textcolor{BrickRed}{(}v\textcolor{BrickRed}{);} \\
\mbox{}\ \ \ \ \textcolor{Red}{\}} \\
\mbox{} \\
\mbox{}\ \ \ \ \textbf{\textcolor{Blue}{if}}\ \textcolor{BrickRed}{(}prev\textcolor{BrickRed}{[}t\textcolor{BrickRed}{]}\ \textcolor{BrickRed}{==}\ \textcolor{BrickRed}{-}\textcolor{Purple}{1}\textcolor{BrickRed}{)}\ \textbf{\textcolor{Blue}{break}}\textcolor{BrickRed}{;} \\
\mbox{} \\
\mbox{}\ \ \ \ \textcolor{ForestGreen}{int}\ bottleneck\ \textcolor{BrickRed}{=}\ INT$\_$MAX\textcolor{BrickRed}{;} \\
\mbox{}\ \ \ \ \textbf{\textcolor{Blue}{for}}\ \textcolor{BrickRed}{(}\textcolor{ForestGreen}{int}\ v\ \textcolor{BrickRed}{=}\ t\textcolor{BrickRed}{,}\ u\ \textcolor{BrickRed}{=}\ prev\textcolor{BrickRed}{[}v\textcolor{BrickRed}{];}\ u\ \textcolor{BrickRed}{!=}\ \textcolor{BrickRed}{-}\textcolor{Purple}{1}\textcolor{BrickRed}{;}\ v\ \textcolor{BrickRed}{=}\ u\textcolor{BrickRed}{,}\ u\ \textcolor{BrickRed}{=}\ prev\textcolor{BrickRed}{[}v\textcolor{BrickRed}{])}\textcolor{Red}{\{} \\
\mbox{}\ \ \ \ \ \ bottleneck\ \textcolor{BrickRed}{=}\ \textbf{\textcolor{Black}{min}}\textcolor{BrickRed}{(}bottleneck\textcolor{BrickRed}{,}\ cap\textcolor{BrickRed}{[}u\textcolor{BrickRed}{][}v\textcolor{BrickRed}{]}\ \textcolor{BrickRed}{-}\ flow\textcolor{BrickRed}{[}u\textcolor{BrickRed}{][}v\textcolor{BrickRed}{]);} \\
\mbox{}\ \ \ \ \textcolor{Red}{\}} \\
\mbox{}\ \ \ \ \textbf{\textcolor{Blue}{for}}\ \textcolor{BrickRed}{(}\textcolor{ForestGreen}{int}\ v\ \textcolor{BrickRed}{=}\ t\textcolor{BrickRed}{,}\ u\ \textcolor{BrickRed}{=}\ prev\textcolor{BrickRed}{[}v\textcolor{BrickRed}{];}\ u\ \textcolor{BrickRed}{!=}\ \textcolor{BrickRed}{-}\textcolor{Purple}{1}\textcolor{BrickRed}{;}\ v\ \textcolor{BrickRed}{=}\ u\textcolor{BrickRed}{,}\ u\ \textcolor{BrickRed}{=}\ prev\textcolor{BrickRed}{[}v\textcolor{BrickRed}{])}\textcolor{Red}{\{} \\
\mbox{}\ \ \ \ \ \ flow\textcolor{BrickRed}{[}u\textcolor{BrickRed}{][}v\textcolor{BrickRed}{]}\ \textcolor{BrickRed}{+=}\ bottleneck\textcolor{BrickRed}{;} \\
\mbox{}\ \ \ \ \ \ flow\textcolor{BrickRed}{[}v\textcolor{BrickRed}{][}u\textcolor{BrickRed}{]}\ \textcolor{BrickRed}{=}\ \textcolor{BrickRed}{-}flow\textcolor{BrickRed}{[}u\textcolor{BrickRed}{][}v\textcolor{BrickRed}{];} \\
\mbox{}\ \ \ \ \textcolor{Red}{\}} \\
\mbox{}\ \ \ \ ans\ \textcolor{BrickRed}{+=}\ bottleneck\textcolor{BrickRed}{;} \\
\mbox{}\ \ \textcolor{Red}{\}} \\
\mbox{}\ \ \textbf{\textcolor{Blue}{return}}\ ans\textcolor{BrickRed}{;} \\
\mbox{}\textcolor{Red}{\}} \\

} \normalfont\normalsize
